#include <CoreFoundation/CoreFoundation.h>
#include <JavaScriptCore/JSStringRefCF.h>
#include <JavaScriptCore/JavaScript.h>

#include <iostream>
#include <thread>

using namespace std;

JSGlobalContextRef globalJSContext;
JSObjectRef globalThis;
void initJSC();
void loadScript();
void readGlobalVariable();
void executeGlobalFunction();
void executeObjectFunction();
string jsValueToStdString(JSGlobalContextRef &context, JSValueRef &jsValue,
                          const CFIndex size);
JSValueRef getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);

JSValueRef callAsFunction(JSContextRef ctx, JSObjectRef function,
                          JSObjectRef thisObject, size_t argumentCount,
                          const JSValueRef arguments[], JSValueRef *exception);

void jsInvoekNative();

class Worker {
private:
  int salary = 1;

public:
  int money = 0;
  void work() { money += salary; }
};